#if !defined(COMMON_UTILS_H__)
#    define COMMON_UTILS_H__

#    pragma once

#    include <QPixmap>
#    include <QProxyStyle>
#    include <QSize>

// 改变系统默认部件风格
class CustomProxyStyle : public QProxyStyle {
public:
    CustomProxyStyle(QObject* parent) {
        setParent(parent);
    }

    virtual void drawPrimitive(PrimitiveElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget = nullptr) {
        if (PE_FrameFocusRect == element) {
            // 去掉window中部件默认的边框或虚线，部件获取焦点时直接返回，不进行绘制
            return;
        }
        else {
            QProxyStyle::drawPrimitive(element, option, painter, widget);
        }
    }
};

// 公共工具
class CommonUtils {
public:
    CommonUtils();

public:
    static QPixmap getRoundImage(const QPixmap& src, QPixmap& mask, QSize masksize = QSize(0, 0));
    static QPixmap getRoundImage(const QPixmap& src, QSize masksize = QSize(0, 0));

    static void   loadStyleSheet(QWidget* widget, const QString& sheetName);
    static void   addStyleSheet(QWidget* widget, const QString& sheetName);
    static void   setDefaultSkinColor(const QColor& color);
    static QColor getDefaultSkinColor();
};

#endif  // COMMON_UTILS_H__
